<?php
/**
 * Filename:	GLineChart.php
 * Author:		Manish Sinha
 * Date:		23/01/09
 * Details:		This file inherits GAbstractChart and add LineChart
 * 				specific properties to the class
 * Project:		GeeCharts
 */

require_once("GAbstractChart.php");
require_once("GAxisStyleLabel.php");

class GLineChart extends GAbstractChart
{
	private $chartTypeEnum = 	array("LINE_AXIS" => "lc",
								"LINE_NOAXIS" => "ls",
								"LINE_XY" => "lxy");
	
	private $chartStyle = null;
	
	public function __construct($x,$y,$type = "LINE_AXIS")
	{
		parent::__construct($x,$y);
		$this->info['cht'] = "cht=".$this->chartTypeEnum[$type];
	}
	
	public function GetURI()
	{
		$uri = "http://chart.apis.google.com/chart?";
		$uri = $uri.$this->baseURI();
		$uri = $uri."&amp;".$this->info['cht'];
		
		$tempdata = array();
		foreach($this->data as $dataset)
		{
			if(is_array($dataset))
				array_push($tempdata,implode(",",$dataset));
		}
		$uri = $uri."&amp;chd=t:".implode("|",$tempdata);
		
		if($this->chartStyle != null)
			$uri = $uri."&amp;".$this->styleURI();
		
		return $uri;
	}
	
	public function AddAxisStyle($styleData)
	{
		if($styleData instanceof GAxisStyleLabel)
		{
			$this->chartStyle = $styleData;
		}
		else
		{
			$this->errormsg = "The object must be an instance of class GAxisStyleLabel";
		}
		
		return $this;
	}
	
	private function styleURI()
	{
		if($this->chartStyle != null)
		{
			$tmparr = $this->chartStyle->GetAxisURI();
			return implode("&amp;",$tmparr);
		}
	}
}
?>
